<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfControlsTest">

    <Style TargetType="{x:Type local:ProjectionContainer}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ProjectionContainer}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <ContentControl Content="{TemplateBinding SelectedItem}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <!--<Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Grid>
                                    <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"/>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>-->
    </Style>

    <Style TargetType="{x:Type local:ProjectiveControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ProjectiveControl}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            x:Name="controlBorder">
                        <ContentControl Grid.Row="1"                                            
                                        x:Name="PART_ContentControl"
                                        Cursor="{TemplateBinding Cursor}" 
                                        HorizontalAlignment="{TemplateBinding HorizontalAlignment}" 
                                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                        FontFamily="{TemplateBinding FontFamily}" 
                                        FontSize="{TemplateBinding FontSize}" 
                                        FontStretch="{TemplateBinding FontStretch}" 
                                        Foreground="{TemplateBinding Foreground}" 
                                        Margin="{TemplateBinding Margin}" 
                                        VerticalAlignment="{TemplateBinding VerticalAlignment}">                                                         
                            <Grid>
                                <Label></Label>
                                <ContentControl Content="{TemplateBinding SelectedItem}"/>
                            </Grid>
                            <ContentControl.ContextMenu>
                                <ContextMenu ItemsSource="{Binding Items, RelativeSource={RelativeSource TemplatedParent}}">
                                    <ContextMenu.Template>
                                        <ControlTemplate>
                                            <ListBox ItemsSource="{Binding Items, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ProjectiveControl}}"
                                                     SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ProjectiveControl}}">
                                                <ListBox.ItemContainerStyle>
                                                    <Style TargetType="{x:Type ListBoxItem}">
                                                        <Setter Property="Content" Value="{Binding Title}"/>
                                                    </Style>
                                                </ListBox.ItemContainerStyle>
                                            </ListBox>
                                        </ControlTemplate>
                                    </ContextMenu.Template>
                                </ContextMenu>
                            </ContentControl.ContextMenu>
                        </ContentControl>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="local:ProjectiveControl.IsProjectiveControlSelected" Value="True">
                            <Setter Property="Border.BorderBrush" Value="LightBlue" TargetName="controlBorder"/>
                            <Setter Property="Border.BorderThickness" Value="1" TargetName="controlBorder"/>
                            <Setter Property="Border.Background" Value="LightBlue" TargetName="controlBorder"/>
                            <Setter Property="ContentControl.Background" Value="LightBlue" TargetName="PART_ContentControl"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>       
    </Style>    

    <Style TargetType="{x:Type local:Projection}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:Projection}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <ContentControl Content="{TemplateBinding Content}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
